var ACTION = require("../../base/action");
var utils = require("../../utils/utils");
var ocrGml = require("../../utils/ocrGml");
var aAward = new ACTION("立即领取", {});
var ad = require("../appCommon/fanQieAd");
aAward.start = function () {
  var content = "加倍领取";
  var UIText = utils.clickTextStartsWith(content);
  if (UIText) {
    sleep(utils.getRandom(3, 4, 1000));
    var content = "加倍领取";
    var ocrItem = ocrGml.captureExistOne(content, true);
    if (ocrItem) {
      utils.clickOcrItem(ocrItem);
      sleep(utils.getRandom(3, 4, 1000));
    }
    return true;
  }
  return false;
};
aAward.exec = function () {
  console.show(true);
  while (this.start()) {
    ad.watchAd();
    sleep(2 * 1000);
    var contentRegExp = /看视频领\d*金币/;
    if (utils.clickTextMatches(contentRegExp)) {
      ad.watchAd();
      sleep(2 * 1000);
    }
  }
  console.hide();
};

module.exports = aAward;
